public class Simulation {

	private static final int NUMBER_OF_EXPERIMENTS = 1000;
	
	public static int simulateTurns(int n, boolean useGui) {
		
		if (useGui)
			new EstablishGui();
		
		
		GameLogic gml = new GameLogic();	
		gml.setUseGui(useGui);
		int i = 0;
		
		while ( !gml.getGame().isGameFinished() && i < n ) {
			gml.performTurn();
			i++;
		}
		
		return i;
		
	}
	
	public static double averegeNumberOfTurns() {
		GameLogic gml = new GameLogic();

		int turns;
		double sumOfTurns = 0;
		
		for (int i = 0; i < NUMBER_OF_EXPERIMENTS; i++) {
			turns = simulateTurns(Integer.MAX_VALUE, false);
			sumOfTurns += turns;
		}
		
		return sumOfTurns / (double) NUMBER_OF_EXPERIMENTS;
		
	}
	
}
